// /config/env.js
/**
 * 通用环境配置文件
 * 支持 App-Plus / H5 / 小程序
 * 统一使用 CommonJS
 */

const PLATFORM = process.env.UNI_PLATFORM || 'app-plus'
const NODE_ENV = process.env.NODE_ENV || 'production'

let BASE_URL = ''
let SOCKET_URL = ''
let ENV_TEXT = ''

if (PLATFORM === 'app-plus') {
  if (NODE_ENV === 'development') {
    // BASE_URL = 'http://192.168.0.177:8182' // 开发
    // SOCKET_URL = 'ws://192.168.0.177:8182/ws'
	BASE_URL = 'http://123.57.49.234:8182' 
	SOCKET_URL = 'ws://123.57.49.234:8182/ws'
    ENV_TEXT = 'App开发环境'
  } else {
    BASE_URL = 'http://123.57.49.234:8182' // 正式
    SOCKET_URL = 'ws://123.57.49.234:8182/ws'
    ENV_TEXT = 'App生产环境'
  }
} else if (PLATFORM === 'h5') {
  BASE_URL = NODE_ENV === 'development' 
    ? 'http://192.168.0.177:8182' 
    : 'https://h5.example.com/api'
  ENV_TEXT = NODE_ENV === 'development' ? 'H5开发环境' : 'H5生产环境'
} else {
  BASE_URL = 'http://123.57.49.234:8182'
  ENV_TEXT = '默认生产环境'
}

console.log('当前环境：', ENV_TEXT)
console.log('接口地址：', BASE_URL)

module.exports = {
  BASE_URL,
  SOCKET_URL,
  ENV_TEXT
}
